<%@ Language=VBScript %>
<%Option Explicit%>

<!--#include file="../cons.asp"-->
<!--#include file="../../Common/Database.asp"-->

<%
	response.CacheControl = "no-cache"
	
	Dim oRSAlumnos
	
	Set oRSAlumnos = GetAlumnosxNombreyApellido(request("txtAlumno"), false)
	%>
	<table cellpadding=0 cellspacing=0 width=100% height=100% style="border-collapse: collapse; font-family: Verndana; font-size: 12px; font-weight: bold; color: white;">
		<tr valign="top">
			<td style="background-color: #666666; width: 250px; height: 15px;">Apellido y Nombre</td>
			<td style="background-color: #666666; text-align: center;">Curso</td>
			<td style="background-color: #666666; text-align: center;">Plan.</td>
			<td style="background-color: #666666; text-align: center; width:20;"></td>
		</tr>
		<tr valign="top">
			<td colspan=5>
				<div style="height: 300px; overflow-Y: scroll;">
		<table cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse; font-family: Verndana; font-size: 12px;">
		<%
			while not oRSAlumnos.EOF
				response.Write "<tr style=""cursor: hand;"" onclick=""divNombreAlumno.innerHTML = 'Materias de: <font color=blue>'+this.cells[0].innerHTML+'</font>' ;GetPromMateriasAlumno(" & oRSAlumnos("IdAlumno") & ");"" onmouseover=""this.style.backgroundColor='yellow';"" onmouseout=""this.style.backgroundColor='';"">"
				response.Write "<td width=250 height=25>" & oRSAlumnos("Apellido") & ", " & oRSAlumnos("Nombre") & "</td>"
				response.Write "<td style=""text-align: center;"">" & server.HTMLEncode(oRSAlumnos("CursoDescrip")) & "</td>"
				response.Write "<td style=""text-align: center;""><img src=""../../images/ico_PlanSeg.gif"" title=""Planilla de Seguimiento"" style=""cursor: hand;"" onclick=""EnPantalla(" & oRSAlumnos("IdAlumno") & "," & oRSAlumnos("IdSede") & ");""></img></td>"
				response.Write "<td></td>"
				response.Write "</tr>"
				
				oRSAlumnos.MoveNext()
			wend
		%>
		</table>
		</div>
		</td>
		</tr>
		
	</table>
<%
Public function GetAlumnosxNombreyApellido(str, countas)

	Dim oConn, sSQL, oRS, astr, i, aux
	
	aux = 0
	if len(str) <= 0 then
		str = "zzzz"
	end if
	astr = split(str, " ")
	
	Set oConn = OpenConnection
	
	if countas then
		sSQL=	"select count(*) "
	else
		sSQL=	"select distinct A.*, C.idSede, C.CursoDescrip "
	end if
			sSQL = sSQL & "from Alumnos A "
			if not countas then
				sSQL = sSQL &	"inner join AlumnosCurso AC on (A.idAlumno=AC.idAlumno) " & _
								"inner join Curso C on (C.IdCurso = AC.idCurso) "
			end if
			for i=0 to ubound(astr)
				if astr(i) <> "" then
					if aux=0 then
						sSQL = sSQL & "where (A.Apellido like '%" & astr(i) & "%' or A.Nombre like '%" & astr(i) & "%')"
						aux=1
					else
						sSQL = sSQL & " and (A.Apellido like '%" & astr(i) & "%' or A.Nombre like '%" & astr(i) & "%')"
					end if
				end if
			Next
			
			sSQL = sSQL & " order by A.Apellido"
	'response.Write sSQL
	'response.End
	
	Set oRS = oConn.Execute(sSQL)
	Set GetAlumnosxNombreyApellido = oRS
End function

%>